import $http from "@/utils/http";
import reuqest from "@/utils/request"

function guid() {
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
    var r = Math.random() * 16 | 0,
      v = c == 'x' ? r : (r & 0x3 | 0x8);
    return v.toString(16);
  });
}

var key = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCVq7n9eWgCZHqVYjAzTUqQ7IV1r0925TPxu13mBdRoI2J1Gdv+CC08DDIUtpmTTex2PUen5WgkJoUKY/h9aY/CCbBsiwtxaEUfUOeJuP/LAOugdi/taF337jniZEXM77Gtzq6XpMmw9BAvjJomoxzWh+4CjEyZtKtn6fvWisO7HwIDAQAB";
export function key(info) {
  let uuid = guid();
  let psd = 'guest#' + uuid
  var encrypt = new JSEncrypt;
  encrypt.setPublicKey(key);
  var encryptData = encrypt.encrypt(psd); //加密后的字符串
  // params.key =encryptData
  return reuqest({
    url: "/guest/login",
    method: 'post',
    params: {
      accountType: "guest",
      account: uuid,
      password: encryptData
    }
  })
}


export function login(info) {
  var encrypt = new JSEncrypt;
  encrypt.setPublicKey(key);
  var encryptData = encrypt.encrypt("123456"); //加密后的字符串
  return reuqest({
    url: "/user/login",
    method: 'post',
    params: {
      bid:"yw",
      account: 13427936865,
      pwd: encryptData,
      accountType: "phone",
    }
  })
}
